package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.mapper.CommentMapper;
import cn.wolfcode.trip.base.query.CommentQueryObject;
import cn.wolfcode.trip.base.service.ICommentService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private ICommentService commentService;
    @Autowired
    private CommentMapper commentMapper;
    @RequestMapping("/list")
    public String list(@ModelAttribute("qo") CommentQueryObject qo, Model model){
        qo.setOrderBy("c.releaseTime desc");
        model.addAttribute("pageInfo",commentService.query(qo));
        PageInfo pageInfo = commentService.query(qo);
        return "comment/list";
    }
    @RequestMapping("/delete")
    public String delete(Long id){
        commentMapper.deleteByPrimaryKey(id);
        return null;
    }
}
